import React, { Component } from 'react';
import { Form } from 'components';
import { FormItemProps, } from 'antd/lib/form/FormItem';
import './style.less'

interface IFormItemProps {
	fieldDecoratorOptions?: any,
	field: string,
	layout?: string,
	render?: any,
	renderType: string,
	options: Array<{ name: string, value: string }>,
	label?: string,
}

export default class extends Component<IFormItemProps, any> {


	render() {
		const { label, field, fieldDecoratorOptions, renderType, options, ...resProps } = this.props;
		switch (renderType) {
			case 'select':
				return (
					<Form.Select
						{...resProps}
						label={label}
						field={field}
						options={options} />
				)
				break;
			case 'rangePicker':
				return (
					<Form.DatePicker.RangePicker
						{...resProps}
						label={label}
						field={field} />
				)
				break;
			default:
				return (
					<Form.Input
						{...resProps}
						label={label}
						field={field} />
				)
				break;
		}
	}
}